import React, { Component } from 'react'
import Swiper from 'swiper/bundle'
import 'swiper/css/bundle'
import 'swiper/css'
export default class LSwiper extends Component {
  componentDidUpdate (prevProps, prevState) {
    // 在更新完成生命周期声明swiper
    new Swiper(".swiper", {
      // 如果需要分页器
      pagination: {
        el: '.swiper-pagination'
      },
      // 是否循环
      loop: this.props.loop
    })
  }
  render () {
    return (
      <div className="swiper" style={{ height: "100px", background: "pink" }}>
        <div className="swiper-wrapper">
          {this.props.children}
        </div>
        {/* <!-- 如果需要分页器 --> */}
        <div className="swiper-pagination"></div>
      </div>
    )
  }
}
